/*******************************************************************************
*  file    : devicestatusboard.hpp
*  created : 30.08.2013
*  author  :
*******************************************************************************/

#ifndef DEVICESTATUSBOARD_HPP
#define DEVICESTATUSBOARD_HPP

#include <QWidget>
#include <QPointer>
#include <QVector>
#include <QModelIndex>

namespace Ui {
class DeviceStatusBoard;
}

class QAbstractItemModel;
class QTimer;

class DeviceStatusBoard : public QWidget
{
    Q_OBJECT

public:
    explicit DeviceStatusBoard(QWidget *parent = 0);
    ~DeviceStatusBoard();

    QAbstractItemModel* model() const;
    void setModel(QAbstractItemModel* model);

public slots:
    void currentChanged(const QModelIndex & current, const QModelIndex & previous);
    void dataChanged   (const QModelIndex & topLeft, const QModelIndex & bottomRight, const QVector<int>& roles);
private slots:
    void onUpdateTime();
private:
    void updateCurrentData();
    void updateTimeElapse();
private:
    Ui::DeviceStatusBoard *ui;
    QPointer<QAbstractItemModel>  model_;
    QModelIndex                   current_;
    QTimer*                       upd_timer_;
};

#endif // DEVICESTATUSBOARD_HPP
